package com.atguigu.gulimail.product.Feign;

import com.atguigu.common.To.SkuReductionTo;
import com.atguigu.common.To.SpuBoundTo;
import com.atguigu.common.utils.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;


@FeignClient("gulimail-coupon")
public interface CouponFeignService {

    /**
     * 1. 当controller调用CouponFeignService.saveSpuBounds(spuBoundTo)方法时
     *      <1> @RequestBody将这个对象转为 JSON
     *      <2> 找到gulimail-coupon服务中的 coupon/spubounds/save 发送请求
     *          将上一步转的JSON放在请求体的位置,发送请求
 *          <3>对方服务接收到请求,对方服务请求体里的JSON数据(@RequestBody SpuBoundEntity spuBound)
     *          会将接收到的JSON转为SpuBoundEntity,只要双方服务数据是兼容的,就可以不适用同一个TO
     *
     * @param spuBoundTo
     * @return
     */
    @PostMapping("coupon/spubounds/save")
    R saveSpuBounds(@RequestBody SpuBoundTo spuBoundTo);

    @PostMapping("coupon/skufullreduction/saveinfo")
    R saveSkuReduction(@RequestBody SkuReductionTo skuReductionTo);
}
